package com.pm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pm.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 用户Mapper接口
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {
    
    /**
     * 根据用户名查找用户
     * @param username 用户名
     * @return 用户信息
     */
    @Select("SELECT id, username, password_hash as passwordHash, email, real_name as realName, avatar, created_at as createdAt, updated_at as updatedAt FROM users WHERE username = #{username}")
    User findByUsername(String username);
    
    /**
     * 根据邮箱查找用户
     * @param email 邮箱
     * @return 用户信息
     */
    @Select("SELECT id, username, password_hash as passwordHash, email, real_name as realName, avatar, created_at as createdAt, updated_at as updatedAt FROM users WHERE email = #{email}")
    User findByEmail(String email);
}